﻿using System;
using Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response;
using Sinacor.Servico.Bovespa.Custodia.BusinessEntity;

namespace Sinacor.Servico.Bovespa.Custodia.Service.ServiceImplementation.Translator
{
    public static class TranslateBetweenPosicaoCustodiaResponseAndPosicaoCustodia
    {
        public static DataContract.Response.PosicaoCustodiaResponse TranslatePosicaoCustodiaToPosicaoCustodiaResponse(BusinessEntity.PosicaoCustodia from)
        {
            if (from == null) return null;
            DataContract.Response.PosicaoCustodiaResponse to = new DataContract.Response.PosicaoCustodiaResponse();
            to.DataPosicao = from.DataPosicao;
            to.Custodia = TranslateBetweenCustodiaAndCustodiaResponse.TranslateCustodiaListToCustodiaResponseList(from.Custodias);
            return to;
        }

        public static BusinessEntity.PosicaoCustodia TranslatePosicaoCustodiaResponseToPosicaoCustodia(DataContract.Response.PosicaoCustodiaResponse from)
        {
            if (from == null) return null;
            BusinessEntity.PosicaoCustodia to = new BusinessEntity.PosicaoCustodia();
            to.DataPosicao = from.DataPosicao;
            to.Custodias = TranslateBetweenCustodiaAndCustodiaResponse.TranslateCustodiaResponseListToCustodiaList(from.Custodia);
            return to;
        }
    }
}
